//
//  StringType.swift
//  swiftStudy
//
//  Created by unisedu on 16/4/1.
//  Copyright © 2016年 CaoFei. All rights reserved.
//

import UIKit
/**
 字符串
 */
class StringType: NSObject {
    
    func show(){
        //字符串
        let strValue:String = "abac"
        debugPrint(strValue)
        //转义字符 \0(null字符串)    \\ \t  \n  \r(回车)  \"  \'
        
        let strValue1="\"asdf\'\t\'"
        debugPrint(strValue1)
        //单字节Unicode字符 使用\xnn表示 ，nn表示两个十六进制数
        //let strValue2 = "\x41" //A
        
        //Unicode字符 使用\unnnn表示 ,n为任意一到八位16进制数且可用的Unicode位码
        let strValue3="\u{2600}"
        let strValue4 = "🌞"
        debugPrint(strValue3)
        debugPrint(strValue4)
        //四字节Unicode字符 使用 \Unnnnnnnn
        
        //let strValue4 = "\U{0001F496}"
        
        //初始化字符串
        let emptyString = ""
        let emptyString2 = String();
        let emptyString3 = "abc"
        let emptyString4 = String("abc")
        debugPrint(emptyString)
        debugPrint(emptyString2)
        debugPrint(emptyString3)
        debugPrint(emptyString4)
        //比较字符串
        if emptyString3 == emptyString4
        {
            print("equal")
        }
        
        //连接字符串 +、＋＝， a+＝b，a＝a+b
        let str1 = "123"
        let str2 = "abc"
        var str = "hhhh\n" + str1 + "," + str2
        var str3 = "bcd\n"
        str3 += "asdfasdf"
        str += str3
        
        //字符串的大小写转换
        let lowercaseStr = "abcdefg"
        let uppercaseStr = lowercaseStr.uppercaseString
        debugPrint(uppercaseStr)
    }
}
